package com.myjoje.controller;

import com.myjoje.service.PubService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 不需要登录可访问
 */
@Controller
@RequestMapping("/pub")
public class PubController {

    @Autowired
    private PubService pubService;


    /**
     * 登录页面，会自动识别手机端和电脑端
     */
    @RequestMapping("/login")
    public String login() {
        return "login";
    }

    /**
     * 无权限直接跳转到登录页面
     */
    @RequestMapping("/need_login")
    public String needLogin() {

        return "redirect:/pub/login";
    }

    /**
     * 验证身份
     */
    @RequestMapping("/validatePrincipal")
    @ResponseBody
    public Object validatePrincipal(String username, String password) {

        return pubService.validatePrincipal(username, password);
    }


}
